package com.lotto.manager.admin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.lotto.manager.admin.dao.GameMapper;
import com.lotto.manager.admin.dao.ItemMapper;
import com.lotto.manager.admin.dao.PlayMapper;
import com.lotto.manager.admin.entity.db.Game;
import com.lotto.manager.admin.entity.db.Item;
import com.lotto.manager.admin.entity.db.Play;
import com.lotto.manager.admin.service.GameService;
import com.lotto.manager.admin.system.SystemData;

public class GameServiceImpl implements GameService{

	
	@Autowired
	private ItemMapper itemMapper;
	
	@Autowired
	private PlayMapper playMapper;
	
	@Autowired
	private GameMapper gameMapper;
	
	@Override
	public void initGame() {
		// TODO Auto-generated method stub
		List<Game> games = gameMapper.selectList(new Game());
		for(Game game:games){
			SystemData.addGame(game.getGameId(), game);
		}
		List<Play> plays = playMapper.selectList(new Play());
		for(Play play:plays){
			play.setGame(SystemData.findGame(play.getGameId()));
			SystemData.addPlay(play.getPlayId(), play);
		}
		
		List<Item> items = itemMapper.selectList(new Item());
		for(Item item:items){
			item.setGame(SystemData.findGame(item.getGameId()));
			item.setPlay(SystemData.findPlay(item.getPlayId()));
			SystemData.addtem(item.getItemId(), item);
		}
		
	}
	
	

}
